Jump to content

- Functions

- # NumberOfLoggedInUsersInGroup

  Followers 0

  Lua → VBScript

  This function returns the number of currently logged in users (regardless if free or busy) into a given group.

  Please see the Introduction chapter for some usage instructions.

      ------------------------------------------------------------------
      -- NumberOfLoggedInUsersInGroup
      --
      -- Returns the number of users which are currently logged in into the given group.
      -- The users need to have a higher status as "1", i.e. being logged in (regardless if free or busy).
      --
      -- Parameter:
      --      sNumber     uname or number of group
      --
      -- Return:
      --      integer     number of logged in users
      ------------------------------------------------------------------
      function NumberOfLoggedInUsersInGroup( sGroup )

          PBXScript.OutputTrace ("-------------> NumberOfLoggedInUsersInGroup ( sGroup = " .. sGroup .. " )")

          local nReturn = 0
          local oUsers  = nil

          oUsers = PBXScript.GetUserByAddress(sGroup)
          if (oUsers ~= nil) then

              for i = 1, #oUsers do

                  PBXScript.OutputTrace ("Found user '" .. oUsers[i]:Name() .. "' with current state '" .. oUsers[i]:State() .. "'")
                  if (oUsers[i]:State() > 1) then nReturn = nReturn + 1

              end
          end

          PBXScript.OutputTrace ("nReturn = " .. tostring(nReturn))
          PBXScript.OutputTrace ("<------------- NumberOfLoggedInUsersInGroup")

          return bReturn
      end

  This function makes use of the Server Script API functions PBXConfig.GetUserByAddress() to resolve all users in the given group to get their status and PBXScript.OutputTrace() to write trace information into the SwyxServer trace file.

  This function is also featured in this blog article.

  By Tom Wellige

  - July 11, 2024
  Share
  Share
  Followers 0
  Previous Page LogCallIntoTextFile()
  Next Page SetNewVoicemailFlag()

## Important Information

By using this site, you agree to our Terms of Use and have taken note of our Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.